package com.jic.interaction.ChinaPost.controller;

import com.jic.common.base.vo.RestResult;
import com.jic.interaction.ChinaPost.model.vo.request.CompensationOrderRequest;
import com.jic.interaction.ChinaPost.model.vo.request.DamagesPayRequest;
import com.jic.interaction.ChinaPost.service.DamagesPayService;
import com.sun.org.apache.xpath.internal.operations.Bool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

/**
 * @Auther YGH
 * @DATE 2020/11/05/15:24
 */
@RestController
@RequestMapping("/damagesPay")
@Api(tags = "赔偿金支付")
@Slf4j
public class DamagesPayController {

    @Resource
    private DamagesPayService damagesPayService;

    /**
    *@Auther: YGH
    *@DATE: 2020/11/5
    *@Return:
    *@Param:
    */
    @ApiOperation(value = "赔偿金支付接口")
    @ResponseBody
    @PostMapping(value = "/callDamagesPay")
    public RestResult<Boolean>  callDamagesPay(@RequestBody @Valid DamagesPayRequest damagesPay) throws InterruptedException, ExecutionException, IOException {
        Long s = damagesPayService.callDamagesPay(damagesPay);

        return RestResult.success(s>0);
    }

    @ApiOperation(value = "赔付金订单核销接口")
    @ResponseBody
    @PostMapping(value = "/callCompensationOrder")
    public RestResult<Boolean>  callCompensationOrder(@RequestBody @Valid CompensationOrderRequest compensationOrder) throws InterruptedException, ExecutionException, IOException {

        Long s = damagesPayService.callCompensationOrder(compensationOrder);

        return RestResult.success(s>0);
    }

}
